//
//  ViewController.m
//  2048练习
//
//  Created by student on 16/3/20.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrolleView;
@property (weak, nonatomic) IBOutlet UIPageControl *pageCotrol;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    for(int i=1;i<=3;i++)
    {
        UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(375*i, 0, 375, 667)];
        imgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"tutorial_%i@2x.png",i]];
        [self.scrolleView addSubview:imgView];
    }
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(375*2.5-372/2/2, 540, 372/2, 85/2)];
    [btn setTitle:@"开始游戏" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn setBackgroundColor:[UIColor grayColor]];
    [btn addTarget:self action:@selector(btnPressed) forControlEvents:UIControlEventTouchUpInside];
    
    [self.scrolleView addSubview:btn];
    
    self.scrolleView.contentSize = CGSizeMake(375*3, 0);
    self.scrolleView.showsHorizontalScrollIndicator = NO;
    self.scrolleView.pagingEnabled = YES;
    
    self.pageCotrol.numberOfPages = 3;
}
-(void)btnPressed
{
    [self performSegueWithIdentifier:@"gotoGame" sender:nil];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.pageCotrol.currentPage = self.scrolleView.contentOffset.x/375.0;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
